#ifndef CAMERA_H_
#define CAMERA_H_

#include "allegro5/allegro.h"
#include "Vector2.h"
#include "Entity.h"
#include <list>

namespace M7engine
{
class Camera
{
public:
	Camera();
	virtual ~Camera();

	bool init(int width, int height);

	void draw(ALLEGRO_DISPLAY *display);

	bool getActive() {return active;}
    void setActive(bool arg) {active = arg;}

    void setID(int arg) {id = arg;}
    int getID() {return id;}

	Vector2 getPosition() {return position;}
	void setPosition(Vector2 arg) {this->position = arg;}
	void setPosition(double x, double y) {position.set(x,y);}
	double getX() {return position.getX();}
	double getY() {return position.getY();}
	void setX(double x) {position.setX(x);}
	void setY(double y) {position.setY(y);}

	void setObject(Entity arg) {objectFollowing = arg;}
	Entity getObject() {return objectFollowing;}

	void setFollowing(bool arg) {isFollowing = arg;}
	bool getFollowing() {return isFollowing;}

	ALLEGRO_BITMAP* getBuffer() {return buffer;}

private:
	int id;
	Vector2 position;
	bool isFollowing, active;
	Entity objectFollowing;
	ALLEGRO_BITMAP *buffer;
};

class CameraManager
{
public:
	CameraManager();
	virtual ~CameraManager();

	bool init();

	void updateCameras();
    void drawCameras(ALLEGRO_DISPLAY *display);
    void cleanCameras();
    void addCamera(Camera *camera);
    Camera *findCamera(int id);
    std::list<Camera*> getCameraList() {return cameras;}
    long getCameraCount() {return (long)cameras.size();}

private:
	std::list<Camera*> cameras;

};
}
#endif
